import {
  mapMutations,
  mapState
} from 'vuex'
export default {
  computed: {
    ...mapState([
      'dataType',
      'userInfo'
    ])
  },
  methods: {
    ...mapMutations([
      'DATA_TYPE'
    ]),
    handleCurrentChange(current) {
      this.currentPage = current
      this._getPage(this.searchForm || {})
    },
    // 获取行业列表
    async _getHangyeData () {
      if (this.dataType.hangyeList.length) return
      const res = await this.$api.classificationPage()
      if (res.code === 200) {
        let data = res.data.rows.filter(item => item.level === '1')
        data.unshift({
          name: '不限',
          id: '',
          level: '1'
        })
        this.$nextTick(() => {
          this.DATA_TYPE({
            type: 'hangyeList',
            data
          })
        })
      }
    },
    // 获取字典列表
    async _getDatatypeList(type, groupId, all = true) {
      if (this.dataType[type] && this.dataType[type].length) return
      return new Promise(async (resolve, reject) => {
        const res = await this.$api.groupListPage({
          groupId
        })
        if (res.code === 200) {
          this.$nextTick(() => {
            this.DATA_TYPE({
              type,
              data: res.data
            })
          })
          resolve(res.data)
        }
      })
    },
  }
}
